import pandas as pd
import logging
from abc import ABC, abstractmethod
from core.normalizer import normalize_account_info, normalize_transaction_flow

logger = logging.getLogger(__name__)

class BaseParser(ABC):
    @abstractmethod
    def parse(self, file_path):
        """解析Excel文件，返回归一化后的开户信息和流水信息 (DataFrames)"""
        pass

    def read_excel_sheets(self, file_path):
        """读取Excel所有Sheet"""
        try:
            sheets = pd.read_excel(file_path, sheet_name=None, engine='openpyxl' if file_path.endswith('.xlsx') else 'xlrd')
            return sheets
        except Exception as e:
            logger.error(f"读取文件 {file_path} 出错: {e}")
            return {}